package com.vhall.component.controller.rbac;


import com.vhall.component.controller.rbac.facade.RbacUserFacade;
import com.vhall.component.entity.rbac.vo.UserAddRoleReqVO;
import com.vhall.component.entity.rbac.vo.UserDeleteRoleReqVO;
import com.vhall.component.entity.rbac.vo.UserGetAccessListReqVO;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.service.rbac.RbacRoleAccessService;
import com.vhall.component.service.rbac.RbacUserRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * @author dalong
 * @date 2021-05-12 20:55
 */
@Api(tags = "RbacUserController", value = "用户权限")
@VhallComponent
@Slf4j
@VssTokenAuth
public class RbacUserController implements RbacUserFacade {

    @Autowired
    private RbacRoleAccessService roleAccessService;

    @Autowired
    private RbacUserRoleService userRoleService;


    @ApiOperation("获取用户权限列表")
    @Override
    public List<Integer> getAccessList(@Validated UserGetAccessListReqVO reqVO) {
        return roleAccessService.getList(reqVO);
    }

    @ApiOperation("增加用户角色")
    @Override
    public Boolean addRole(@Validated UserAddRoleReqVO reqVO) {
        return userRoleService.batchCreate(reqVO);
    }

    @ApiOperation("删除用户角色")
    @Override
    public Boolean deleteRoleAction(@Validated UserDeleteRoleReqVO reqVO) {
        return userRoleService.batchDelete(reqVO);
    }
}
